const ResCode = require("../config/ResCode");
const Stype = require("../config/Stype");
const Cmd = require("../config/Cmd");
const dt = require("../proto/DT");
const log = require("../utils/log");



class MsgMode{
    constructor() {

    }

    // 编码Msg
    encodeMsg(stype, ctype, buf,code = ResCode.Ok){
        let ret = {
            code:ResCode.Ok,
            stype: Stype.Auth,
            ctype: Cmd.Auth.LoginRes,
            buffer:buf
        }
        let encodeMsg = dt.encodeMsgRes(ret);
        log.error('===============解码 Msg================',dt.decodeMsgRes(encodeMsg));
        return encodeMsg;
    }

    //解码
    decodeMsg(buf){
        let obj = dt.decodeMsgRes(buf);
        return obj;
    }

}

module.exports = MsgMode